package com.alveole.events.browser;

import com.alveole.events.handlers.BrowserEventHandler;

public class BrowserEventFactory {
	@SuppressWarnings("unchecked")
	public static BrowserEvent createBrowserEvent(String command)
	{
		// fetching
	BrowserEvent event = null;
	
	try {
		String packg=BrowserEventHandler.class.getName()
				.substring(0,BrowserEventHandler.class.getName().length()
						-BrowserEventHandler.class.getSimpleName().length());
		Class<BrowserEvent> clazz = (Class<BrowserEvent>) 
				Class.forName(packg + 
				"Browser" + command +"Event");
		event = clazz.newInstance();
	} catch (ClassNotFoundException e2) {
		// TODO Auto-generated catch block
	} catch (InstantiationException e) {
		// TODO Auto-generated catch block
	} catch (IllegalAccessException e) {
		// TODO Auto-generated catch block
	}
	if (event==null)
		event=new BrowserUnknownEvent(command);

	return event;
	}
}
